import React from 'react'
import { Menu } from 'antd';
import { MailOutlined, AppstoreOutlined, SettingOutlined,LayoutOutlined, ShareAltOutlined ,RestOutlined} from '@ant-design/icons';
import {NavLink} from 'react-router-dom'
import userpathsFn from '../../grants'

import './aside.css'

const { SubMenu } = Menu;


export default class Aside extends React.Component {
  
  constructor(props){
    super()
    this.state = {
      userpaths:[]
    }
  }
  
  //获取筛选过后新的用户权限路由配置
  componentDidMount(){
      this.setState({
          userpaths:userpathsFn()
      })
  }
  
  isshowmeau(meaupath){
    console.log('userpathsFn()',userpathsFn());
      let res = userpathsFn().some((item)=>item.path==meaupath)
      return res

  }

  render() {

    return (
      <>    
        <Menu
          style={{ width: 161 }}
          defaultOpenKeys={['sub1']}
          // defaultSelectedKeys={['1']}
          mode="inline"
          theme = 'light'
        >
          <SubMenu key="sub1" icon={<MailOutlined />} title="用户管理">

              {/* {
                 this.state.userpaths.map((item,idx)=>(

                  <Menu.Item key={idx}>
                      <NavLink to={item.path} activeClassName="tochange">
                          {item.title}
                      </NavLink>
                  </Menu.Item>
                 ))
                  
              } */}
                  <Menu.Item key="1" style={{display:this.isshowmeau('/layouts/userlist')?"block":"none"}}>
                      <NavLink to="/layouts/userlist" activeClassName="tochange">
                    用户列表
                      </NavLink>
                    </Menu.Item>
                  <Menu.Item key="2" style={{display:this.isshowmeau('/layouts/commuinfo')?"block":"none"}}>
                        <NavLink to="/layouts/commuinfo" activeClassName="tochange">
                    通讯信息
                        </NavLink>
                    </Menu.Item>
                  <Menu.Item key="3" style={{display:this.isshowmeau('/layouts/userstati')?"block":"none"}}>
                    <NavLink to="/layouts/userstati" activeClassName="tochange">
                        统计分析
                      </NavLink>
                  </Menu.Item>
          </SubMenu>
          <SubMenu key="sub2" icon={<AppstoreOutlined />} title="商户管理">
              <Menu.Item key="4" style={{display:this.isshowmeau('/layouts/merchanlist')?"block":"none"}}>
                  <NavLink to="/layouts/merchanlist" activeClassName="tochange">
                      商户列表
                  </NavLink>
              </Menu.Item>
              <Menu.Item key="5" style={{display:this.isshowmeau('/layouts/loginaccou')?"block":"none"}}>
                  <NavLink to="/layouts/loginaccou" activeClassName="tochange">
                      登录账户
                  </NavLink>
              </Menu.Item>
              <Menu.Item key="6" style={{display:"none"}}>登录记录</Menu.Item>
              <Menu.Item key="7" style={{display:"none"}}>资质信息</Menu.Item>
              <Menu.Item key="8" style={{display:this.isshowmeau('/layouts/merchas')?"block":"none"}}>
                  <NavLink to="/layouts/merchas" activeClassName="tochange">
                      商户分析
                  </NavLink>
              </Menu.Item>
          </SubMenu>  
          <SubMenu key="sub3" icon={<LayoutOutlined />} title="订单管理">
              <Menu.Item key="9" style={{display:this.isshowmeau('/layouts/orderlist')?"block":"none"}}>
                  <NavLink to="/layouts/orderlist" activeClassName="tochange">
                      订单列表
                  </NavLink>
              </Menu.Item>
              <Menu.Item key="10" style={{display:this.isshowmeau('/layouts/orderstati')?"block":"none"}}>
                  <NavLink to="/layouts/orderstati" activeClassName="tochange">
                      统计分析
                  </NavLink>
              </Menu.Item>
          </SubMenu>
          <SubMenu key="sub4" icon={<SettingOutlined />} title="收支管理">
            <Menu.Item key="11" style={{display:"none"}}>收支列表</Menu.Item>
            <Menu.Item key="12" style={{display:"none"}}>收支分析</Menu.Item>
          </SubMenu>
          <SubMenu key="sub5" icon={<RestOutlined />} title="平台管理">
            <Menu.Item key="13" style={{display:"none"}}>管理中心</Menu.Item>
            <Menu.Item key="14" style={{display:"none"}}>短信管理</Menu.Item>
            <Menu.Item key="15" style={{display:"none"}}>促销信息</Menu.Item>
            <Menu.Item key="16" style={{display:"none"}}>基本设置</Menu.Item>
          </SubMenu>
          <SubMenu key="sub6" icon={<ShareAltOutlined />} title="安全管理">
            <Menu.Item key="17" style={{display:"none"}}>基本信息</Menu.Item>
            <Menu.Item key="18" style={{display:"none"}}>密码设置</Menu.Item>
          </SubMenu>
        </Menu>
      </>
    );
  }
}

